package com.youlu.campus.admin.vote.controller;

import com.alibaba.fastjson.JSON;

import com.youlu.campus.admin.vote.dto.UserVoteSaveDTO;
import com.youlu.campus.admin.vote.dto.UserVoteSearchDTO;
import com.youlu.campus.admin.vote.service.UserVoteAdminService;
import com.yuelin.infrastructure.quantum.common.QResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户投票api
 *
 * @author : [dengbo]
 * @className : VoteOrgController
 * @description : [组织信息]
 * @createTime : [2022/7/4 09:59]
 */
@Slf4j
@RestController
public class UserVoteAdminController {

    @Autowired
    private UserVoteAdminService UserVoteAdminService;

    /**
     * 用户投票信息修改
     * @param request
     * @return
     */
    @PostMapping("/user-vote/save")
    public QResult save(@Validated @RequestBody UserVoteSaveDTO request) {
        log.info("UserVoteController,save,request param:{}", JSON.toJSONString(request));
        return QResult.success(UserVoteAdminService.save(request));
    }

    /**
     * 用户投票信息搜索
     * @param request
     * @return
     */
    @PostMapping("/user-vote/search")
    public QResult search(@Validated @RequestBody UserVoteSearchDTO request) {
        log.info("UserVoteController,search,request param:{}", JSON.toJSONString(request));
        return QResult.success(UserVoteAdminService.search(request));
    }
}
